

const defaultState = {
	articleDetail: {},
	mask: false,
	commentList: [],
	dialog: false,
	replyId: '',
	commentForm: {
		nickName: '',
		email: '',
		content: ''
	}
}

export default (state=defaultState, action) => {
	switch(action.type) {
		case 'change_detail': 
			return {
				...state,
				articleDetail: action.value
			}
		case 'change_mask': 
			return {
				...state,
				mask: action.value
			}
		case 'change_dialog':
			return {
				...state,
				dialog: action.value,
				replyId: action.replyId
			}
		case 'change_commentList': 
			return {
				...state,
				commentList: action.value
			}
		case 'change_replyId': 
			return {
				...state,
				replyId: action.value
			}
		case 'change_commentForm':
			let newState = {...state}
			newState.commentForm[action.valueType] = action.value
			return newState
		default: 
			return state
	}
}